package com.lzy.mall.product.web;

import com.lzy.mall.product.service.PmsSkuInfoService;
import com.lzy.mall.product.vo.SkuItemVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.concurrent.ExecutionException;

/**
 * @author lzy
 * @date 2021/9/22 11:08
 */
@Controller
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class ItemWeb {
    private final PmsSkuInfoService skuInfoService;

    /**
     * 展示sku详情
     * @param skuId
     * @param model
     */
    @RequestMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId") Long skuId, Model model) throws ExecutionException, InterruptedException {

        SkuItemVo vo = skuInfoService.item(skuId);
        System.out.println(vo);
        model.addAttribute("item", vo);
        return "item";
    }
}
